package com.ctshk.sapp.system.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.req.MainData;
import com.ctshk.rpc.system.dto.mian.data.MainDataComprehensiveServiceDetailDTO;
import com.ctshk.rpc.system.dto.mian.data.MainDataComprehensiveServiceListDTO;
import com.ctshk.rpc.system.req.MainDataCollectionTypeDetailReq;
import com.ctshk.rpc.system.req.MainDataCollectionTypeListReq;
import com.ctshk.rpc.system.req.main.data.MainDataComprehensiveServiceAddReq;
import com.ctshk.rpc.system.req.main.data.MainDataComprehensiveServiceIdReq;
import com.ctshk.rpc.system.req.main.data.MainDataComprehensiveServiceListReq;
import com.ctshk.rpc.system.req.main.data.MainDataComprehensiveServiceQueryListReq;
import com.ctshk.rpc.system.service.IMainDataComprehensiveServiceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 主数据-综费服务类型 前端控制器
 * </p>
 *
 * @author 叶冠峰
 * @since 2021-06-03
 */
@RestController
@Api(value="综费服务", tags="综费服务")
@RequestMapping("/main-data-comprehensive")
public class MainDataComprehensiveServiceController extends BaseController {

    @DubboReference
    private IMainDataComprehensiveServiceService mainDataComprehensiveServiceService;

    @ApiOperation(value = "列表", notes = "列表")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.QUERY, operTitle = "列表", operDesc = "列表")
    @PostMapping("/list")
    public Result<PageResponse<MainDataComprehensiveServiceListDTO>> list(@RequestBody MainDataComprehensiveServiceListReq req) {
        return mainDataComprehensiveServiceService.list(req);
    }

    @ApiOperation(value = "查询列表", notes = "查询列表")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.QUERY, operTitle = "查询列表", operDesc = "查询列表")
    @GetMapping("/query/{name}")
    public Result<List<MainData>> query(@PathVariable String name) {
        return mainDataComprehensiveServiceService.query(name);
    }

    @ApiOperation(value = "详情", notes = "详情")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.QUERY, operTitle = "详情", operDesc = "详情")
    @PostMapping("/detail")
    public Result<MainDataComprehensiveServiceDetailDTO> detail(@RequestBody @Valid MainDataComprehensiveServiceIdReq req) {
        return mainDataComprehensiveServiceService.detail(req);
    }

    @ApiOperation(value = "新增/编辑", notes = "新增/编辑")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.ADD, operTitle = "新增/编辑", operDesc = "新增/编辑")
    @PostMapping("/add")
    public Result add(@RequestBody @Valid MainDataComprehensiveServiceAddReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return mainDataComprehensiveServiceService.add(req);
    }

    @ApiOperation(value = "删除", notes = "删除")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.UPDATE, operTitle = "删除", operDesc = "删除")
    @PostMapping("/del")
    public Result del(@RequestBody @Valid MainDataComprehensiveServiceIdReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return mainDataComprehensiveServiceService.del(req);
    }

    @ApiOperation(value = "修改状态", notes = "修改状态")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.UPDATE, operTitle = "修改状态", operDesc = "修改状态")
    @PostMapping("/change-status")
    public Result changeStatus(@RequestBody @Valid MainDataComprehensiveServiceIdReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return mainDataComprehensiveServiceService.changeStatus(req);
    }

}
